package com.findyou.validation;

import com.findyou.anno.State;
import jakarta.validation.ConstraintValidator;
import jakarta.validation.ConstraintValidatorContext;

/**
 * @Title: StateCalidation
 * @Author 贾金博
 * @Package com.findyou.validation
 * @Date 2024/3/9 20:41
 * @description: 这里的State指的是给哪个注解提供 String
 * 指的是校验的参数的类型是什么
 */
public class StateValidation implements ConstraintValidator<State, String> {

    @Override
    public boolean isValid(String s, ConstraintValidatorContext constraintValidatorContext) {
        if(s == null)
            return false; // 校验不通过
        if(s.equals("草稿") || s .equals("已发布"))
            return true;
        return false;
    }
}
